<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>keyczar.util</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="keyczar-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >Keyczar</th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="keyczar-module.html">Package&nbsp;keyczar</a> ::
        Module&nbsp;util
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="keyczar.util-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module util</h1><p class="nomargin-top"><span class="codelink"><a href="keyczar.util-pysrc.html">source&nbsp;code</a></span></p>
<p>Utility functions for keyczar package.</p>

<hr />
<div class="fields">      <p><strong>Author:</strong>
        arkajit.dey@gmail.com (Arkajit Dey)
      </p>
</div><!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Functions</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Functions"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="ASN1Sequence"></a><span class="summary-sig-name">ASN1Sequence</span>(<span class="summary-sig-arg">*vals</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#ASN1Sequence">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="ParseASN1Sequence"></a><span class="summary-sig-name">ParseASN1Sequence</span>(<span class="summary-sig-arg">seq</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#ParseASN1Sequence">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="ParsePkcs8"></a><span class="summary-sig-name">ParsePkcs8</span>(<span class="summary-sig-arg">pkcs8</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#ParsePkcs8">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="ExportRsaPkcs8"></a><span class="summary-sig-name">ExportRsaPkcs8</span>(<span class="summary-sig-arg">params</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#ExportRsaPkcs8">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="ExportDsaPkcs8"></a><span class="summary-sig-name">ExportDsaPkcs8</span>(<span class="summary-sig-arg">params</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#ExportDsaPkcs8">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="ParseX509"></a><span class="summary-sig-name">ParseX509</span>(<span class="summary-sig-arg">x509</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#ParseX509">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="ExportRsaX509"></a><span class="summary-sig-name">ExportRsaX509</span>(<span class="summary-sig-arg">params</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#ExportRsaX509">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="ExportDsaX509"></a><span class="summary-sig-name">ExportDsaX509</span>(<span class="summary-sig-arg">params</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#ExportDsaX509">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">string</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="keyczar.util-module.html#MakeDsaSig" class="summary-sig-name">MakeDsaSig</a>(<span class="summary-sig-arg">r</span>,
        <span class="summary-sig-arg">s</span>)</span><br />
      Given the raw parameters of a DSA signature, return a Base64 
      signature.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#MakeDsaSig">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">tuple</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="keyczar.util-module.html#ParseDsaSig" class="summary-sig-name">ParseDsaSig</a>(<span class="summary-sig-arg">sig</span>)</span><br />
      Given a raw byte string, return tuple of DSA signature parameters.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#ParseDsaSig">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="MakeEmsaMessage"></a><span class="summary-sig-name">MakeEmsaMessage</span>(<span class="summary-sig-arg">msg</span>,
        <span class="summary-sig-arg">modulus_size</span>)</span><br />
      Algorithm EMSA_PKCS1-v1_5 from PKCS 1 version 2</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#MakeEmsaMessage">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="BinToBytes"></a><span class="summary-sig-name">BinToBytes</span>(<span class="summary-sig-arg">bits</span>)</span><br />
      Convert bit string to byte string.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#BinToBytes">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="BytesToBin"></a><span class="summary-sig-name">BytesToBin</span>(<span class="summary-sig-arg">bytes</span>)</span><br />
      Convert byte string to bit string.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#BytesToBin">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_PadByte"></a><span class="summary-sig-name">_PadByte</span>(<span class="summary-sig-arg">bits</span>)</span><br />
      Pad a string of bits with zeros to make its length a multiple of 8.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#_PadByte">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="IntToBin"></a><span class="summary-sig-name">IntToBin</span>(<span class="summary-sig-arg">n</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#IntToBin">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="BigIntToBytes"></a><span class="summary-sig-name">BigIntToBytes</span>(<span class="summary-sig-arg">n</span>)</span><br />
      Return a big-endian byte string representation of an arbitrary length
      n.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#BigIntToBytes">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="IntToBytes"></a><span class="summary-sig-name">IntToBytes</span>(<span class="summary-sig-arg">n</span>)</span><br />
      Return byte string of 4 big-endian ordered bytes representing n.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#IntToBytes">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="BytesToInt"></a><span class="summary-sig-name">BytesToInt</span>(<span class="summary-sig-arg">bytes</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#BytesToInt">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="Xor"></a><span class="summary-sig-name">Xor</span>(<span class="summary-sig-arg">a</span>,
        <span class="summary-sig-arg">b</span>)</span><br />
      Return a ^ b as a byte string where a and b are byte strings.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#Xor">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_PadBytes"></a><span class="summary-sig-name">_PadBytes</span>(<span class="summary-sig-arg">bytes</span>,
        <span class="summary-sig-arg">n</span>)</span><br />
      Prepend a byte string with n zero bytes.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#_PadBytes">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_TrimBytes"></a><span class="summary-sig-name">_TrimBytes</span>(<span class="summary-sig-arg">bytes</span>)</span><br />
      Trim leading zero bytes.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#_TrimBytes">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="RandBytes"></a><span class="summary-sig-name">RandBytes</span>(<span class="summary-sig-arg">n</span>)</span><br />
      Return n random bytes.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#RandBytes">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="Hash"></a><span class="summary-sig-name">Hash</span>(<span class="summary-sig-arg">*inputs</span>)</span><br />
      Return a SHA-1 hash over a variable number of inputs.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#Hash">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">string</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="keyczar.util-module.html#Encode" class="summary-sig-name">Encode</a>(<span class="summary-sig-arg">s</span>)</span><br />
      Return Base64 encoding of s.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#Encode">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">string</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="keyczar.util-module.html#Decode" class="summary-sig-name">Decode</a>(<span class="summary-sig-arg">s</span>)</span><br />
      Return decoded version of given Base64 string.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#Decode">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="keyczar.util-module.html#WriteFile" class="summary-sig-name">WriteFile</a>(<span class="summary-sig-arg">data</span>,
        <span class="summary-sig-arg">loc</span>)</span><br />
      Writes data to file at given location.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#WriteFile">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">string</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="keyczar.util-module.html#ReadFile" class="summary-sig-name">ReadFile</a>(<span class="summary-sig-arg">loc</span>)</span><br />
      Read data from file at given location.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#ReadFile">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">string</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="keyczar.util-module.html#MGF" class="summary-sig-name">MGF</a>(<span class="summary-sig-arg">seed</span>,
        <span class="summary-sig-arg">mlen</span>)</span><br />
      Mask Generation Function (MGF1) with SHA-1 as hash.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="keyczar.util-pysrc.html#MGF">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Variables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="HLEN"></a><span class="summary-name">HLEN</span> = <code title="20">20</code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="RSA_OID"></a><span class="summary-name">RSA_OID</span> = <code title="ObjectIdentifier('1.2.840.113549.1.1.1')">ObjectIdentifier('1.2.840.113549.1.1.1')</code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="RSA_PARAMS"></a><span class="summary-name">RSA_PARAMS</span> = <code title="['n', 'e', 'd', 'p', 'q', 'dp', 'dq', 'invq']"><code class="variable-group">[</code><code class="variable-quote">'</code><code class="variable-string">n</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">e</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">d</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">p</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">q</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">dp</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">dq</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">invq</code><code class="variable-quote">'</code><code class="variable-group">]</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="DSA_OID"></a><span class="summary-name">DSA_OID</span> = <code title="ObjectIdentifier('1.2.840.10040.4.1')">ObjectIdentifier('1.2.840.10040.4.1')</code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="DSA_PARAMS"></a><span class="summary-name">DSA_PARAMS</span> = <code title="['p', 'q', 'g']"><code class="variable-group">[</code><code class="variable-quote">'</code><code class="variable-string">p</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">q</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">g</code><code class="variable-quote">'</code><code class="variable-group">]</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="SHA1RSA_OID"></a><span class="summary-name">SHA1RSA_OID</span> = <code title="ObjectIdentifier('1.2.840.113549.1.1.5')">ObjectIdentifier('1.2.840.113549.1.1.5')</code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="SHA1_OID"></a><span class="summary-name">SHA1_OID</span> = <code title="ObjectIdentifier('1.3.14.3.2.26')">ObjectIdentifier('1.3.14.3.2.26')</code>
    </td>
  </tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Function Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-FunctionDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="MakeDsaSig"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">MakeDsaSig</span>(<span class="sig-arg">r</span>,
        <span class="sig-arg">s</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="keyczar.util-pysrc.html#MakeDsaSig">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Given the raw parameters of a DSA signature, return a Base64 
  signature.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>r</code></strong> (long int) - parameter r of DSA signature</li>
        <li><strong class="pname"><code>s</code></strong> (long int) - parameter s of DSA signature</li>
    </ul></dd>
    <dt>Returns: string</dt>
        <dd>raw byte string formatted as an ASN.1 sequence of r and s</dd>
  </dl>
</td></tr></table>
</div>
<a name="ParseDsaSig"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">ParseDsaSig</span>(<span class="sig-arg">sig</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="keyczar.util-pysrc.html#ParseDsaSig">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Given a raw byte string, return tuple of DSA signature parameters.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>sig</code></strong> (string) - byte string of ASN.1 representation</li>
    </ul></dd>
    <dt>Returns: tuple</dt>
        <dd>parameters r, s as a tuple</dd>
    <dt>Raises:</dt>
    <dd><ul class="nomargin-top">
        <li><code><strong class='fraise'>KeyczarErrror</strong></code> - if the DSA signature format is invalid</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="Encode"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">Encode</span>(<span class="sig-arg">s</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="keyczar.util-pysrc.html#Encode">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Return Base64 encoding of s. Suppress padding characters (=).</p>
  <p>Uses URL-safe alphabet: - replaces +, _ replaces /. Will convert s of 
  type unicode to string type first.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>s</code></strong> (string) - string to encode as Base64</li>
    </ul></dd>
    <dt>Returns: string</dt>
        <dd>Base64 representation of s.</dd>
  </dl>
</td></tr></table>
</div>
<a name="Decode"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">Decode</span>(<span class="sig-arg">s</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="keyczar.util-pysrc.html#Decode">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Return decoded version of given Base64 string. Ignore whitespace.</p>
  <p>Uses URL-safe alphabet: - replaces +, _ replaces /. Will convert s of 
  type unicode to string type first.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>s</code></strong> (string) - Base64 string to decode</li>
    </ul></dd>
    <dt>Returns: string</dt>
        <dd>original string that was encoded as Base64</dd>
    <dt>Raises:</dt>
    <dd><ul class="nomargin-top">
        <li><code><strong class='fraise'><a href="keyczar.errors.Base64DecodingError-class.html">Base64DecodingError</a></strong></code> - If length of string (ignoring whitespace) is one more than a 
        multiple of four.</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="WriteFile"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">WriteFile</span>(<span class="sig-arg">data</span>,
        <span class="sig-arg">loc</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="keyczar.util-pysrc.html#WriteFile">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Writes data to file at given location.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>data</code></strong> (string) - contents to be written to file</li>
        <li><strong class="pname"><code>loc</code></strong> (string) - name of file to write to</li>
    </ul></dd>
    <dt>Raises:</dt>
    <dd><ul class="nomargin-top">
        <li><code><strong class='fraise'><a href="keyczar.errors.KeyczarError-class.html">KeyczarError</a></strong></code> - if unable to write to file because of IOError</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="ReadFile"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">ReadFile</span>(<span class="sig-arg">loc</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="keyczar.util-pysrc.html#ReadFile">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Read data from file at given location.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>loc</code></strong> (string) - name of file to read from</li>
    </ul></dd>
    <dt>Returns: string</dt>
        <dd>contents of the file</dd>
    <dt>Raises:</dt>
    <dd><ul class="nomargin-top">
        <li><code><strong class='fraise'><a href="keyczar.errors.KeyczarError-class.html">KeyczarError</a></strong></code> - if unable to read from file because of IOError</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="MGF"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">MGF</span>(<span class="sig-arg">seed</span>,
        <span class="sig-arg">mlen</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="keyczar.util-pysrc.html#MGF">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Mask Generation Function (MGF1) with SHA-1 as hash.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>seed</code></strong> (string) - used to generate mask, a byte string</li>
        <li><strong class="pname"><code>mlen</code></strong> (integer) - desired length of mask</li>
    </ul></dd>
    <dt>Returns: string</dt>
        <dd>mask, byte string of length mlen</dd>
    <dt>Raises:</dt>
    <dd><ul class="nomargin-top">
        <li><code><strong class='fraise'><a href="keyczar.errors.KeyczarError-class.html">KeyczarError</a></strong></code> - if mask length too long, &gt; 2^32 * hash_length</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="keyczar-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >Keyczar</th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sun Aug 10 17:05:05 2008
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
